package com.chinatelecom.epush.widge;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.chinatelecom.epush.R;
import com.chinatelecom.epush.db.SharedPreferencesData;
import com.chinatelecom.epush.index.LoginAppActivity;


public class CommonTitleLayout extends LinearLayout {
	private Context context;
	private View view;
	private Button btnHome;
	private Button btnBack;
	private SharedPreferencesData spData;
	private String sheme;
	private FrameLayout flBackground;

	public CommonTitleLayout(Context context) {
		super(context);
		this.context = context;
		initView();
	}

	public CommonTitleLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		initView();
	}

	private void initView() {
		LayoutInflater inflater = (LayoutInflater) getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view = inflater.inflate(R.layout.common_title, this, true);

		btnHome = (Button) view.findViewById(R.id.btn_home);
		btnHome.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, LoginAppActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				context.startActivity(intent);
			}
		});

		btnBack = (Button) view.findViewById(R.id.btn_back);
		btnBack.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Activity activity = (Activity) context;
				activity.finish();
			}
		});

		spData = new SharedPreferencesData(context);
		flBackground = (FrameLayout) view.findViewById(R.id.frame_bg);
		sheme = spData.getSheme();
	}
}
